<?php if (!defined('__TYPECHO_ROOT_DIR__')) exit; ?>

<form class="navbar-form panel-body" id="search" method="post" action="./" role="search">
  <div class="input-group">
  <div class="form-control-wrapper"><input type="text" placeholder="搜索" class="form-control empty" name="s"><span class="material-input"></span></div>
    <span class="input-group-btn">
      <button class="btn btn-primary btn-fab mdi-action-search" id="search-btn" type="submit"></button>
    </span>
  </div>
  <!-- /input-group -->
</form>

<?php if (!empty($this->options->sidebarBlock) && in_array('ShowRecentPosts', $this->options->sidebarBlock)): ?>
  <div class="panel panel-primary">
    <a class="panel-heading" onclick="$('.recent_posts_box').slideToggle()" href="javascript:;">
      <h3 class="panel-title"><?php _e('最新文章'); ?></h3>
    </a>
    <div class="recent_posts_box">
      <?php $this->widget('Widget_Contents_Post_Recent')
        ->parse('<a class="item" href="{permalink}">{title}</a>'); ?>
    </div>
  </div>
<?php endif; ?>

<?php if (!empty($this->options->sidebarBlock) && in_array('ShowRecentComments', $this->options->sidebarBlock)): ?>
  <div class="panel panel-primary">
    <a class="panel-heading" onclick="$('.comment_box').slideToggle()" href="javascript:;">
      <h3 class="panel-title"><?php _e('最近回复'); ?></h3>
    </a>
    <div class="comment_box">
      <?php $this->widget('Widget_Comments_Recent', 'ignoreAuthor=true')->to($comments); ?>
      <?php while($comments->next()): ?>
        <a class="item" href="<?php $comments->permalink(); ?>" title="<?php $comments->excerpt(35, '...'); ?>"><?php $comments->author(false); ?>: <?php $comments->excerpt(35, '...'); ?></a>
      <?php endwhile; ?>
    </div>
  </div>
<?php endif; ?>

<?php if (!empty($this->options->sidebarBlock) && in_array('ShowCategory', $this->options->sidebarBlock)): ?>
<div class="panel panel-primary">
  <a class="panel-heading" onclick="$('.archive-category').slideToggle()" href="javascript:;">
    <h3 class="panel-title"><?php _e('分类'); ?></h3>
  </a>
  <div class="archive-category">
    <?php $this->widget('Widget_Metas_Category_List')
      ->parse('<a class="item" href="{permalink}">{name}</a>'); ?>
  </div>
</div>
<?php endif; ?>

<?php if (!empty($this->options->sidebarBlock) && in_array('ShowArchive', $this->options->sidebarBlock)): ?>
<div class="panel panel-primary">
    <a class="panel-heading" onclick="$('.archive-box').slideToggle()" href="javascript:;">
        <h3 class="panel-title"><?php _e('归档'); ?></h3>
    </a>
    <div class="archive-box">
        <?php $this->widget('Widget_Contents_Post_Date', 'type=year&format=Y')
            ->parse('<a class="item" href="{permalink}">{date}</a>'); ?>
    </div>
</div>
<?php endif; ?>

<?php if (!empty($this->options->sidebarBlock) && in_array('ShowOther', $this->options->sidebarBlock)): ?>
  <div class="panel panel-info">
    <a class="panel-heading" onclick="$('.tool_box').slideToggle()" href="javascript:;">
      <h3 class="panel-title"><?php _e('其它'); ?></h3>
    </a>
    <div class="tool_box">
      <?php if($this->user->hasLogin()): ?>
        <a class="item" href="<?php $this->options->adminUrl(); ?>"><?php _e('进入后台'); ?> (<?php $this->user->screenName(); ?>)</a>
        <a class="item" href="<?php $this->options->logoutUrl(); ?>"><?php _e('退出'); ?></a>
      <?php else: ?>
        <a class="item" href="<?php $this->options->adminUrl('login.php'); ?>"><?php _e('登录'); ?></a>
      <?php endif; ?>
      <a class="item" href="<?php $this->options->feedUrl(); ?>"><?php _e('文章 RSS'); ?></a>
      <a class="item" href="<?php $this->options->commentsFeedUrl(); ?>"><?php _e('评论 RSS'); ?></a>
    </div>
  </div>
<?php endif; ?>
